//
//  TodayDetailViewController.m
//  SYiDaiy
//
//  Created by dllo on 16/8/29.
//  Copyright © 2016年 dllo. All rights reserved.


#import "TodayDetailViewController.h"
#import "TAMacro.h"
#import "AFNetworking.h"
#import "Esarray.h"
#import "CustomWebview.h"
#import "TodayDetailTopViewController.h"

@interface TodayDetailViewController ()<UICollectionViewDataSource,UIScrollViewDelegate,UIWebViewDelegate>
@property (nonatomic,strong) NSArray *entry_imgsArray;

@property (nonatomic,strong) CustomWebview *webView;

@property (nonatomic,strong) UICollectionView *todayDetailCollectionView;

@property (nonatomic,strong) UICollectionViewFlowLayout *topFlow;
@property (nonatomic,strong) UITableView *todayTopTableView;




@end

@implementation TodayDetailViewController


#pragma mark ---------today详情viewDidLoad方法
- (void)viewDidLoad {
    [super viewDidLoad];

    
    [self creatTodayDetailCollectionView];
    
}










#pragma mark -----创建TodayDetailCollectionView的方法
- (void)creatTodayDetailCollectionView
{
    UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
    _todayDetailCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49) collectionViewLayout:flow];
    _todayDetailCollectionView.backgroundColor = [UIColor whiteColor];
    _todayDetailCollectionView.dataSource = self;
    _todayDetailCollectionView.pagingEnabled = YES;
    
    
    CGPoint point = CGPointMake(_rowValue * SCREEN_WIDTH, 0);
    [_todayDetailCollectionView setContentOffset:point];
    

    flow.itemSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 49);
    flow.minimumInteritemSpacing = 0;
    flow.minimumLineSpacing = 0;
    flow.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    [self.view addSubview:_todayDetailCollectionView];
    [_todayDetailCollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"todayDetailCollectionViewCell"];
    

    [self.todayDetailCollectionView reloadData];
    
}


#pragma mark ---------today详情集合视图返回cell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"todayDetailCollectionViewCell" forIndexPath:indexPath];
    [cell addSubview:_todayTopTableView];
     Esarray *esarray = [[self totayArr] objectAtIndex:indexPath.row];
    TodayDetailTopViewController *top = [TodayDetailTopViewController new];
    top.entry_imgsArray = esarray.entry_imgs;
    [self addChildViewController:top];
   
    [cell.contentView addSubview:top.view];
    _webView = [[CustomWebview alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT / 667 * 160, SCREEN_WIDTH, SCREEN_HEIGHT - 160 - 64 - 49)];
    [cell.contentView addSubview:_webView];
    [_webView passStr:esarray.link_share];

    return cell;
}

#pragma mark -------today详情集合视图item个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
     return _totayArr.count;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    

}






@end
